<?php
class AuthController extends Zend_Controller_Action
{
    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
        $request = $this->getRequest();
        
        if ($request->isPost()){
        	$username = $request->getPost('username');
        	$password = $request->getPost('password');
        	
        	$user = new Sc_User();
        	$user->username = $username;
        	$user->password = $password;
        	
        	$service = new Sc_Service_User();
        	$result = $service->authorize($user);
        	if ($result != false) {
        		$session = new Zend_Session_Namespace(Sc_Util_Const::SC_NAMESPACE);
        		$session->user = $result;
        		
        		$this->_redirect("comment");
        	}
        }
    }

	function logoutAction(){
		$session = new Zend_Session_Namespace(Sc_Util_Const::SC_NAMESPACE);
        $session->unsetAll();
        
        $this->_redirect("auth");
	}
}

